<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="100px"
    >
      <el-form-item label="项目名称" prop="extractItem">
        <el-input
          v-model="queryParams.extractItem"
          placeholder="请输入项目名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="抽取人单位" prop="createBy">
        <el-select
          v-model="form.createBy"
          placeholder="请选择抽取人单位"
          clearable
          size="small"
          style="width: 100%"
          @change="UnitTypeChangepenson"
        >
          <el-option
            v-for="type in unitTypeponsonOptions"
            :key="type.userId"
            :label="type.nickName"
            :value="type.userId"
          />
        </el-select>
      </el-form-item> -->
      <el-form-item label="抽取库" prop="randomUnittypeId">
        <el-select
          v-model="form.randomUnittypeId"
          placeholder="请选择抽取库"
          clearable
          size="small"
          style="width: 100%"
          @change="UnitTypeChange"
        >
          <el-option
            v-for="type in unitTypeOptions"
            :key="type.unittypeId"
            :label="type.unittypeName"
            :value="type.unittypeId"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['unit:extract:add']"
          >新增</el-button
        >
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd2"
          v-hasPermi="['unit:extract:add']"
        >
          新增施工项目
        </el-button>
      </el-col> -->
      <!-- <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['unit:extract:edit']"
        >修改</el-button>
      </el-col> -->
      <!-- <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['unit:extract:remove']"
        >删除</el-button>
      </el-col> -->
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['unit:extract:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="extractList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="项目名称" align="left" prop="extractItem" />
      <el-table-column label="经办人" align="left" prop="extractCharge" />
      <el-table-column
        label="中介机构服务费（万元）"
        align="left"
        prop="maxPrice"
      />
      <el-table-column
        label="创建时间"
        align="center"
        prop="updateTime"
        :formatter="updateTimeTime"
      />
      <el-table-column
        label="抽取库"
        align="left"
        width="200"
        prop="unitTypeName"
      />
      <el-table-column
        label="审批状态"
        align="center"
        prop="extractApproveStatus"
        :formatter="approveStatusFormat"
      />
      <!-- <el-table-column label="建设地址" align="left" prop="extractAddress" />
      <el-table-column
        label="抽取人单位"
        align="left"
        prop="createBy"
        width="250"
      />
      <el-table-column label="工程费用" align="left" prop="extractPrice" /> -->
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['unit:extract:edit']"
            v-if="scope.row.extractApproveStatus == 0"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-printer"
            @click="handleUpdatePrint(scope.row)"
            v-hasPermi="['unit:extract:edit']"
            >打印</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['unit:extract:remove']"
            v-if="scope.row.extractApproveStatus == 0"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改项目申请对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="1200px"
      append-to-body
      @close="closeDialog"
      :close-on-click-modal="false"
    >
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="125px"
        size="mini"
      >
        <el-row>
          <el-row :gutter="15">
            <el-form-item label="申请单位" prop="createBy">{{
              form.createBy
            }}</el-form-item>
          </el-row>
          <el-row :gutter="15">
            <el-col
              :span="12"
              style="padding-top: -20px; padding-bottom: -50px"
            >
              <el-form-item label="项目名称" prop="extractItem">
                <el-input
                  v-model="form.extractItem"
                  placeholder="请输入项目名称"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="建设周期" prop="extractPeriod">
                <el-input
                  v-model="form.extractPeriod"
                  placeholder="请输入建设周期"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="15">
            <el-col :span="12">
              <el-form-item label="工程费用(万元)" prop="extractPrice">
                <el-input
                  v-model="form.extractPrice"
                  placeholder="请输入工程费用"
                  type="number"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="中介机构服务费（万元）"
                prop="maxPrice"
                label-width="185px"
              >
                <el-input
                  v-model="form.maxPrice"
                  placeholder="请输入中介机构服务费"
                  type="number"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item label="工程概况" prop="projectOverview">
            <el-input
              v-model="form.projectOverview"
              type="textarea"
              placeholder="请输入工程概况"
            />
          </el-form-item>
        </el-row>
        <el-row>
          <el-row :gutter="15">
            <el-col :span="12">
              <el-form-item label="经办人" prop="extractCharge">
                <el-input
                  v-model="form.extractCharge"
                  placeholder="请输入经办人"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="联系电话" prop="extractPhone">
                <el-input
                  v-model="form.extractPhone"
                  placeholder="请输入联系电话"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item label="抽取要求" prop="extractBanReason">
            <el-input
              v-model="form.extractBanReason"
              type="textarea"
              placeholder="请输入抽取要求"
            />
          </el-form-item>

          <el-form-item label="业务类型" prop="extractBusinessType">
            <el-input
              class="commonWidth"
              v-model="form.extractBusinessType"
              placeholder="请输入业务类型"
            ></el-input>
            <div class="ceshi">
              *招标代理（勘察、设计）、工程造价咨询（跟踪审计）等
            </div>
          </el-form-item>
          <el-form-item label="是否驻场服务">
            <el-radio-group v-model="form.extractResident">
              <el-radio label="0">是</el-radio>
              <el-radio label="1">否</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-row>
            <el-col :span="12" v-if="form.extractResident === '0'">
              <el-form-item label="驻场服务人数" prop="extractResidentNumber">
                <el-input
                  v-model="form.extractResidentNumber"
                  placeholder="请填写驻场服务人数"
                  type="number"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12" v-if="form.extractResident === '0'">
              <el-form-item label="完成时限" prop="extractLimitedTime">
                <el-date-picker
                  v-model="form.extractLimitedTime"
                  value-format="yyyy-MM-dd"
                  type="date"
                  placeholder="选择完成时限"
                  style="width: 100%"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="15">
            <!-- 旧 -->
            <!-- <el-col :span="12">
		      <el-form-item label="选择抽取库" prop="randomUnittypeId">
		        <el-select v-model="form.randomUnittypeId" placeholder="请选择抽取库" clearable size="small" style="width:100%;" @change="UnitTypeChange">
		          <el-option
		            v-for="type in unitTypeOptions"
		            :key="type.unittypeId"
		            :label="type.unittypeName"
		            :value="type.unittypeId"
		          />
		        </el-select>
		      </el-form-item>
		    </el-col> -->
            <!-- 新 -->
            <el-col :span="12">
              <el-form-item label="选择抽取库" prop="unitIdsTypeName">
                <el-input
                  placeholder="请选择抽取库"
                  @click.native="
                    addUnitInfo(
                      form.unitIds,
                      form.unitIdsTypeName,
                      form.unitIdsTypeId
                    )
                  "
                  v-model="form.unitIdsTypeName"
                  readonly
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="抽取单位数" prop="extractNumber">
                <el-input
                  v-model="form.extractNumber"
                  type="number"
                  placeholder="请输入抽取单位数"
                  oninput="if(value){value=value.replace(/[^\d]/g,'')} if(value<1){value=1}"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-form-item v-if="form.extractResident === '0'" label="驻场要求">
              <el-input
                v-model="form.extractStationRequire"
                placeholder="请填写驻场要求"
              />
            </el-form-item>
          </el-row>
        </el-row>
        <!-- 库下对应单位表格 -->
        <el-row v-if="unittype!='15'">
            <el-table
            v-loading="loading"
            id="unitTable"
            :data="unitList"
            max-height="400"
            :row-style="rowStyle"
          >
            <el-table-column
              label="序号"
              align="center"
              prop="unitSort"
              width="100"
            />
            <el-table-column
              label="单位名称"
              align="left"
              prop="unitName"
              width="310"
            />
            <el-table-column
              label="资质"
              align="left"
              prop="unitNaturalGrade"
              width="150"
              v-if="showmake"
            />
            <el-table-column
              label="是否选择"
              align="center"
              prop="isTick"
              width="120"
            >
              <template slot-scope="scope" v-if="unittype!='15'">
                {{ scope.row.isTick == 1 ? "是" : "否" }}
              </template>
            </el-table-column>
            <!-- <el-table-column
              label="是否可用"
              align="center"
              prop="extractPrice"
              :formatter="AutomaticApproveStatusFormat"
              width="120"
            >
              <template slot-scope="scope">
                {{scope.row.forbidden == 0 ? "否" : "是"}}
              </template>
            </el-table-column>
            <el-table-column
              label="排除理由"
              align="left"
              prop="eliminateReason"
              width="200"
            /> -->
            <el-table-column
              label="操作"
              align="center"
              class-name="small-padding fixed-width"
            >
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-edit"
                  @click="unitShow(scope.row)"
                  v-hasPermi="['unit:extract:edit']"
                  >单位详情</el-button
                >
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-circle-close"
                  @click="overcome(scope.row)"
                  v-if="scope.row.unitStatues == 0"
                  v-show="false"
                  >排除</el-button
                >
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-refresh-right"
                  @click="DeleteMappingBtn(scope.row)"
                  v-if="scope.row.unitStatues == 1"
                >
                  还原
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-row>
        <el-row v-else>
          <el-table
            v-loading="loading"
            id="unitTable"
            :data="agentlist"
            max-height="400"
            :row-style="rowStyle"
          >
            <el-table-column
              label="编号"
              align="center"
              prop="agentid"
              width="100"
            />
            <el-table-column
              label="招标人代表姓名"
              align="center"
              prop="name"
              width="310"
            />
            <el-table-column
              label="专业"
              align="left"
              prop="speciality"
              width="350"
            />
            <el-table-column
              label="类别"
              align="center"
              prop="professionType"
              width="200"
            />
            <el-table-column
              label="是否选择"
              align="center"
              prop="isTick"
              width="150"
            >
              <template slot-scope="scope">
                {{ scope.row.isTick == 1 ? "是" : "否" }}
              </template>
            </el-table-column>
          </el-table>
        </el-row>

        <el-form-item
          label="签字表"
          label-width="130px"
          style="margintop: 30px"
        >
          <el-upload
            class="upload-demo other"
            :disabled="uploadDisabled"
            :accept="acceptType"
            ref="uploadFile"
            action=""
            :show-file-list="false"
            :http-request="uploadFile"
          >
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">
              请上传bmp，gif，jpg，jpeg，png文件，且不超过10MB
            </div>
          </el-upload>

          <div class="image-wrap" v-if="imgUrl.length > 0">
            <div
              class="uploadimg-wrap"
              v-for="(item, index) in imgUrl"
              :key="index"
            >
              <el-image
                style="width: 100px; height: 100px"
                :src="item"
                fit="cover"
                :preview-src-list="imgUrl"
                :z-index="3000"
              >
              </el-image>
              <i class="icon el-icon-error" @click="removeImg(index)"></i>
            </div>
          </div>
        </el-form-item>
      </el-form>
      <div v-if="form.extractApproveIdea != null">
        <h3>审批意见</h3>
        <div class="reason-wrap" style="display: flex">
          <div class="reason-title">审批结果</div>
          <div class="reason">
            {{ form.extractApproveStatus == 0 ? "拒绝" : "同意" }}
          </div>
        </div>
        <div class="reason-wrap" style="display: flex">
          <div class="reason-title">备注</div>
          <div class="reason">{{ form.extractApproveIdea }}</div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button ref="xx" type="primary" @click="submitForm">提交</el-button>
        <el-button type="primary" @click="saveForm">保存</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 打印项目申请对话框 -->
    <el-dialog
      :title="titlePrint"
      :visible.sync="openPrint"
      width="800px"
      append-to-body
    >
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="120px"
        style="width: 700px; padding-left: 50px"
      >
        <table
          class="printTable"
          border="1"
          cellspacing="0"
          cellpadding="0"
          id="printMe"
          width="100%"
          height="800px"
          @formatter="unitTypeFormat"
        >
          <caption align="top" class="title">
            {{
              form.unitTypeId == "11"
                ? "重庆高新开发建设投资集团有限公司非公招项目施工单位抽选申请表"
                : "重庆高新开发建设投资集团有限公司中介机构抽取申请表"
            }}
          </caption>
          <template v-if="form.unitTypeId != '11'">
            <tr>
              <td
                colspan="3"
                height="40px"
                class="topfont topfont-name noBorder"
              >
                申请单位：{{ form.createBy }}
              </td>
              <td
                colspan="2"
                class="topfont topfont-name noBorder"
                style="text-align: right"
              >
                日期：{{ form.createTime | dateTime }}
              </td>
            </tr>
            <tr>
              <td rowspan="3" width="100px" class="bigfont">
                项 目 基<br />本 情 况
              </td>
              <td width="150px" height="60px" class="small project-name">
                项 目 名 称
              </td>
              <th colspan="3" class="input project-name-1 rightBorder">
                {{ form.extractItem }}
              </th>
            </tr>
            <tr>
              <td height="60px" class="small project-name">建 设 地 址</td>
              <th colspan="3" class="input font-family rightBorder">
                {{ form.extractAddress }}
              </th>
            </tr>
            <tr>
              <td width="80px" height="60px" class="small project-name">
                工 程 费 用<br />(万 元)
              </td>
              <th width="130px" class="input font-family">
                {{ form.extractPrice }}
              </th>
              <td width="130px" class="small project-name">建 设 周 期</td>
              <th class="input font-family rightBorder">
                {{ form.extractPeriod }}
              </th>
            </tr>
            <tr>
              <td rowspan="10" class="bigfont bottomBorder">
                抽 取 库<br />信 息
              </td>
              <td height="60px" class="small project-name">抽 取 库</td>
              <th class="input font-family rightBorder" colspan="3">
                {{ form.unitTypeName }}
              </th>
            </tr>
            <tr>
              <td height="60px" class="small project-name">业 务 类 型</td>
              <th class="input font-family rightBorder" colspan="3">
                {{ form.extractBusinessType }}
              </th>
            </tr>
            <tr>
              <td
                height="60px"
                colspan="4"
                class="zhong project-name rightBorder"
              >
                中介机构服务费（万元）：{{ form.maxPrice }}
              </td>
            </tr>
            <tr>
              <td
                colspan="4"
                class="fontitem1 project-name rightBorder"
                height="90px"
              >
                抽取要求：<br />{{ form.extractBanReason }}
              </td>
            </tr>
            <tr>
              <td
                colspan="4"
                class="fontitem12 project-name rightBorder"
                height="40px"
              >
                是否驻场服务：
                {{ form.extractResident == 0 ? "是" : "否" }}
              </td>
            </tr>
            <tr>
              <td height="80px" class="small project-name">
                驻场服务人数(至少)
              </td>
              <th class="input font-family">
                {{
                  form.extractResident == 0 ? form.extractResidentNumber : ""
                }}
              </th>
              <th class="small project-name">完成时限</th>
              <th class="input font-family rightBorder">
                {{ form.extractResident == 0 ? form.extractLimitedTime : "" }}
              </th>
            </tr>
            <tr>
              <td height="60px" class="small project-name">驻 场 要 求</td>
              <th class="input font-family rightBorder" colspan="3">
                {{
                  form.extractResident == 0 ? form.extractStationRequire : ""
                }}
              </th>
            </tr>
            <tr>
              <td height="60px" class="small project-name">
                经 办 人(联 系 人)
              </td>
              <th class="input font-family">{{ form.extractCharge }}</th>
              <td class="small project-name">联 系 电 话</td>
              <th class="input font-family rightBorder">
                {{ form.extractPhone }}
              </th>
            </tr>
            <tr>
              <td
                rowspan="2"
                height="120px"
                colspan="4"
                class="fontitem1 project-name rightBorder bottomBorder"
              >
                经办部门或子公司负责人意见：
              </td>
            </tr>
          </template>

          <template v-else>
            <tr>
              <td
                colspan="3"
                height="40px"
                class="topfont topfont-name noBorder"
              >
                申请单位：{{ form.createBy }}
              </td>
              <td
                colspan="2"
                class="topfont topfont-name noBorder"
                style="text-align: right"
              >
                日期：{{ form.createTime | dateTime }}
              </td>
            </tr>
            <tr>
              <td rowspan="5" width="100px" class="bigfont">
                项 目 基<br />本 情 况
              </td>
              <td width="150px" height="60px" class="small project-name">
                项 目 名 称
              </td>
              <th colspan="3" class="input project-name-1 rightBorder">
                {{ form.extractItem }}
              </th>
            </tr>
            <tr>
              <td height="60px" class="small project-name">建 设 地 址</td>
              <th colspan="3" class="input font-family rightBorder">
                {{ form.extractAddress }}
              </th>
            </tr>
            <tr>
              <td width="80px" height="60px" class="small project-name">
                工 程 费 用<br />(万 元)
              </td>
              <th width="130px" class="input font-family">
                {{ form.extractPrice }}
              </th>
              <td width="130px" class="small project-name">建 设 周 期</td>
              <th class="input font-family rightBorder">
                {{ form.extractPeriod }}
              </th>
            </tr>
            <tr>
              <td width="80px" height="60px" class="small project-name">
                经办人<br />(联系人)
              </td>
              <th width="130px" class="input font-family">
                {{ form.extractCharge }}
              </th>
              <td width="130px" class="small project-name">联系电话</td>
              <th class="input font-family rightBorder">
                {{ form.extractPhone }}
              </th>
            </tr>
            <tr>
              <td
                colspan="4"
                class="fontitem1 project-name rightBorder"
                height="120px"
              >
                工程概况:<br />{{ form.projectOverview }}
              </td>
            </tr>

            <tr>
              <td rowspan="4" class="bigfont bottomBorder">抽取<br />信息</td>
              <td width="150px" height="60px" class="small project-name">
                暂定中介服务费<br />(万 元)
              </td>
              <th colspan="3" class="input project-name-1 rightBorder">
                {{ form.maxPrice }}
              </th>
            </tr>
            <tr>
              <td
                colspan="4"
                class="fontitem1 project-name rightBorder"
                height="120px"
              >
                抽取要求:<br />{{ form.extractBanReason }}
              </td>
            </tr>
            <tr>
              <td
                rowspan="2"
                height="120px"
                colspan="4"
                class="fontitem1 project-name rightBorder bottomBorder"
              >
                经办部门或子公司负责人意见：
              </td>
            </tr>
          </template>
        </table>
        <el-button
          v-print="'#printMe'"
          type="primary"
          style="margin-top: 10px; margin-left: 90%"
          >打 印</el-button
        >
      </el-form>
    </el-dialog>

    <!-- 单位信息对话框 -->
    <!-- <el-dialog
      :title="title"
      :visible.sync="unitopen"
      width="60%"
      append-to-body
    >
      <div class="unitSort-box">
        <unitDetail :formUnit="formUnit"></unitDetail>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormUnit">确 定</el-button>
      </div>
    </el-dialog> -->
    <DetailDialog :visible.sync="unitopen" :formUnit="formUnit" />
    <!-- 排除弹出框 -->
    <el-dialog
      :title="title"
      :visible.sync="exclude"
      width="500px"
      append-to-body
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-form-item label="排除理由" prop="maxPrice">
          <el-input
            v-model="form.randomBanRansom"
            type="textarea"
            cols="5"
            rows="5"
            placeholder="请输入排除理由"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="excludeSave">保存</el-button>
        <el-button @click="call">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 排除理由查看框    placeholder="请输入排除理由" type="textarea" cols="5" rows="5" -->
    <el-dialog
      :title="title1"
      :visible.sync="outframe"
      width="700px"
      append-to-body
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-input
          v-model="form.randomBanRansom"
          type="textarea"
          cols="10"
          rows="10"
        />
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="determined">确定</el-button>
      </div>
    </el-dialog>

    <!-- 单位信息对话框-方式2-表格方式 -->
    <unitInfoTable
      :tableData="tableData"
      :loading="loading"
      ref="unitInfo"
      :centerDialogVisible.sync="centerDialogVisible"
    ></unitInfoTable>
  </div>
</template>

<script>
import {
  listExtract,
  getExtract,
  delExtract,
  addExtract,
  updateExtract,
  exportExtract,
  addBanRandom,
  CheckReason,
  submit,
  Department,
} from "@/api/unit/extract";
import FileUpload from "@/components/FileUpload";
import {
  listUnit,
  randomlist,
  getUnit,
  delUnit,
  addUnit,
  updateUnit,
  exportUnit,
  agentlist,
} from "@/api/unit/unit";
import { listUnittype, getUnittype } from "@/api/unit/unittype";
import { listUser } from "@/api/system/user";
import { listRandom, getRandomMsg, DeleteMapping } from "@/api/unit/random";
import service from "../../components/utils/request.js";
import unitDetail from "@/common/unitDetail/unitDetail";
import unitInfoTable from "@/views/unit/extract/view/components/unitInfo";
import DetailDialog from "@/common/detailDialog";

export default {
  name: "ExtractIndex",
  components: {
    FileUpload,
    unitDetail,
    unitInfoTable,
    DetailDialog
  },
  data() {
    return {
      disabled: false,
      //控制资质列隐藏显示
      showmake: true,
      //打开预览
      innerVisible: false,
      //禁用上传按钮
      uploadDisabled: false,
      //动态控制rowspan
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 签字表
      extractSignUrl: [],
      //抽取人单位字典
      unitTypeponsonOptions: [],
      // 项目申请表格数据
      extractList: [],
      // 单位信息表格数据
      unitList: [],
      // 招标招标人代表表格数据
      agentlist: [],
      // 单位类型字典
      unitTypeOptions: [],
      // 弹出层标题
      title: "",
      title1: "你的排除理由如下:",
      titlePrint: "",
      // 是否显示弹出层
      open: false,
      openPrint: false,
      unitopen: false,
      exclude: false,
      outframe: false,
      unitId: "",
      unittype: "",
      randomUnitName: "",
      Random: {
        randomUnittypeId: null,
        randomBanRansom: null,
        randomUnitId: null,
        randomUnitName: null,
      },
      // 排除项目集合
      RandomList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        extractItem: null,
        extractUser: null,
        extractAddress: null,
        extractPrice: null,
        extractApproveStatus: null,
        maxPrice: null,
        randomUnittypeId: null,
        userId: null,
      },
      // 查询参数
      RandomqueryParams: {
        pageNum: 1,
        pageSize: 10,
        extractId: null,
        randomUnitId: null,
        randomBan: "0",
        annex: null,
      },
      RandomqueryParamsList: {
        pageNum: 1,
        pageSize: 10,
        extractId: null,
        randomUnitId: null,
        annex: null,
      },
      UnitqueryParams: {
        pageNum: 1,
        pageSize: 10,
        extractId: null,
        unitName: null,
        unitNaturalGrade: null,
        unitNaturalScope: null,
        unitRemarks: null,
        unitType: null,
      },
      // 表单参数
      form: {
        extractResident: "0", //是否驻场服务
        extractResidentNumber: "", // 驻场服务人数
        extractLimitedTime: "", //完成时限
        extractStationRequire: "", //驻场要求
        extractBusinessType: "", // 业务类型
        unitIds: "", //抽取单位ids
        unitIdsTypeName: "", //抽取单位类型名字
        unitIdsTypeId: "", //抽取类型ID
        rows: "", //所勾选行数据数组
      },
      //单位详情
      formUnit: {},
      randomList: {
        extractId: null,
        randomBanRansom: null,
        randomUnittypeId: null,
        randomUnitName: null,
        randomUnitId: null,
      },
      // 表单校验
      rules: {
        extractAddress: [
          { required: true, message: "建设地址不能为空", trigger: "blur" },
        ],
        maxPrice: [
          {
            required: true,
            message: "中介机构服务费不能为空",
            trigger: "blur",
          },
        ],
        extractPrice: [
          { required: true, message: "工程费用不能为空", trigger: "blur" },
        ],
        extractPeriod: [
          { required: true, message: "建设周期不能为空", trigger: "blur" },
        ],
        extractResidentNumber: [
          { required: true, message: "驻场服务人数不能为空", trigger: "blur" },
        ],
        extractLimitedTime: [
          { required: true, message: "完成时限不能为空", trigger: "blur" },
        ],
        extractPhone: [
          { required: true, message: "联系电话不能为空", trigger: "blur" },
        ],
        extractItem: [
          { required: true, message: "项目名称不能为空", trigger: "blur" },
        ],
        unitIdsTypeName: [
          { required: true, message: "抽取库不能为空", trigger: "change" },
        ],
        extractCharge: [
          { required: true, message: "经办人不能为空", trigger: "blur" },
        ],
        extractNumber: [
          { required: true, message: "抽取单位数不能为空", trigger: "blur" },
        ],
        extractBusinessType: [
          { required: true, message: "业务类型不能为空", trigger: "blur" },
        ],
      },
      // 上传文件的图片地址
      imgUrl: [],
      // 接受的文件类型
      acceptType: "bmp,gif,jpg,jpeg,png",
      // 图片类型
      imageType: "bmp,gif,jpg,jpeg,png",

      //抽取机构数据
      tableData: [],
      centerDialogVisible: false,
    };
  },
  created() {
    this.getList();
    listUnittype().then((response) => {
      this.unitTypeOptions = response.rows;
    });
    listUser().then((response) => {
      this.unitTypeponsonOptions = response.rows;
    });
  },
  methods: {
    //渲染抽取单位数据
    addUnitInfo(unitIds, unitIdsTypeName, unitIdsTypeId) {
      //01-调用子组件方法
      this.centerDialogVisible = true;
      const queryParams = {
        unitIds: unitIds == "undefined" ? "" : unitIds,
        unitIdsTypeName: unitIdsTypeName == "undefined" ? "" : unitIdsTypeName,
        unitIdsTypeId: unitIdsTypeId == "undefined" ? "" : unitIdsTypeId,
      };
      this.$refs.unitInfo.unitTypeInfo(queryParams);

      const $this = this;
      // setTimeout(function () {
      //   if (unitIdsTypeId == 11) {
      //     $this.$refs.unitInfo.data2 = true;
      //   } else {
      //     $this.$refs.unitInfo.data2 = false;
      //   }
      // }, 500);
    },

    //为排除的单位添加颜色区分
    tableRowClassName({ row, rowIndex }) {
      if (row.unitStatues === 1) {
        return "denger-row";
      } else if (row.unitStatues === 2) {
        return "denger-row";
      } else if (row.unitStatues === 3) {
        return "denger-row";
      }
      return "";
    },
    //else if(row.unitNaturalGrade.length>10){
    //	 return 'success-row';}
    /** 查询项目申请列表 */
    async getList() {
      this.loading = true;
      await Department(this.queryParams).then((response) => {
        this.queryParams.userId = response.data.userId;
      });
      /** 只查询未提交、申请中、审批通过的项目 */
      this.queryParams.extractApproveStatus = "0,1,2";
      listExtract(this.queryParams).then((response) => {
        this.extractList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.imgUrl = [];
      this.reset();
    },
    //抽取人单位
    UnitTypeChangepenson(value) {
      listUser().then((response) => {
        for (var o = 0; o < response.rows.length; o++) {
          if (value == response.rows[o].userId) {
            this.queryParams.createBy = response.rows[o].nickName;
          }
        }
      });
    },
    //手动排除翻译状态
    ManualApproveStatusFormat(row, column) {
      if (row.unitStatues == 0) {
        return "否";
      } else if (row.unitStatues == 1) {
        return "是";
      } else if (row.unitStatues == 2) {
        return "否";
      } else if (row.unitStatues == 3) {
        return "否";
      } else if (row.randomBan == 4) {
        return "未中标";
      } else if (row.randomBan == 5) {
        return "废除报价";
      }
    },
    //自动排除翻译状态
    AutomaticApproveStatusFormat(row, column) {
      if (row.unitStatues == 0) {
        return "否";
      } else if (row.unitStatues == 1) {
        return "否";
      } else if (row.unitStatues == 2) {
        return "是";
      } else if (row.unitStatues == 3) {
        return "是";
      } else if (row.randomBan == 4) {
        return "未中标";
      } else if (row.randomBan == 5) {
        return "废除报价";
      }
    },
    // 上传文件，获取文件地址
    async uploadFile(eleFile) {
      const file = eleFile.file;
      let fileType = file.type;
      fileType = fileType.split("/");
      fileType = fileType[fileType.length - 1];
      // 判断文件大小
      if (file.size > 10 * 1024 * 1024) {
        this.$message.error("文件大小不能超过10MB");
        return;
      }
      // 判断文件类型
      if (!this.acceptType.includes(fileType)) {
        this.$message.error("文件类型不正确");
        let uid = file.uid;
        let idx = this.$refs.uploadFile.uploadFiles.findIndex(
          (item) => item.id === uid
        );
        this.$refs.uploadFiles.splice(idx, 1);
        return;
      }
      // 判断文件个数
      if (this.imgUrl.length > 2) {
        this.$message.error("最多只能上传三个文件");
        return;
      }
      const fd = new FormData();
      fd.append("file", file);
      try {
        const res = await service.post("/common/upload", fd, {
          headers: { "content-type": "multipart/form-data" },
        });
        if (res.code === 200) {
          const obj = {
            name: file.name,
            url: res.url,
          };
          if (this.imageType.includes(fileType)) {
            this.imgUrl.push(res.url);
          }
          this.form.extractSignUrl = this.imgUrl;
          this.$message({
            message: "上传成功",
            type: "success",
          });
        }
      } catch (e) {
        this.$message.error(e);
      }
    },
    closeDialog() {
      this.form.extractSignUrl = [];
      this.imgUrl = [];
    },
    // 表单重置
    reset() {
      this.form = {
        extractId: null,
        extractItem: null,
        extractUser: null,
        extractAddress: null,
        extractPrice: null,
        extractPeriod: null,
        extractRemarks: null,
        extractApproveStatus: null,
        extractCharge: null,
        extractBanReason: null,
        extractPhone: null,
        extractScore: null,
        maxPrice: null,
        randomUnittypeId: null,
        createBy: null,
        createTime: null,
        extractPlace: null,
        quoteEndTime: null,
        updateBy: null,
        updateTime: null,
        extractPriceUrl: null,
        extractSignUrl: null,
        extractResident: "1",
        extractResidentNumber: null,
        extractLimitedTime: null,
        bussessType: null,
        userId: null,
        unitTypeName: null,
        extractNumber: null,
        unitIds: null,
        unitIdsTypeName: null,
      };
      this.resetForm("form");
    },
    //单位详情表单重置
    resetUnit() {
      this.formUnit = {
        unitId: null,
        unitSort: null,
        unitType: null,
        unitName: null,
        unitNaturalGrade: null,
        unitNaturalScope: null,
        unitAddress: null,
        unitRemarks: null,
      };
    },
    // 单位库类型翻译
    unitTypeFormat(row, column) {
      return this.selecttypeLabel(this.unitTypeOptions, row.randomUnittypeId);
    },
    //时间翻译
    updateTimeTime(row, column) {
      if (row.updateTime?.length > 10) {
        return row.updateTime.substr(0, 10);
      }
    },
    //转换单位库类型
    selecttypeLabel(datas, value) {
      var actions = [];

      Object.keys(datas).some((key) => {
        if (datas[key].unittypeId == "" + value) {
          actions.push(datas[key].unittypeName);
          return true;
        }
      });
      return actions.join("");
    },
    //单位选择select改变方法
    UnitTypeChange(value) {
      //让table显现出来
      //查询table数据
      this.UnitqueryParams.unitType = value;
      this.UnitqueryParams.extractId = this.form.extractId;
      if (
        this.UnitqueryParams.unitType == 1 ||
        this.UnitqueryParams.unitType == 4 ||
        this.UnitqueryParams.unitType == 3 ||
        this.UnitqueryParams.unitType == 9
      ) {
        this.showmake = false;
      } else {
        this.showmake = true;
      }
      randomlist(this.UnitqueryParams).then((response) => {
        this.unitList = response.rows;
        this.loading = false;
      });
    },
    //根据单位库类型，查询出对应单位列表
    getRandomList() {
      randomlist(this.UnitqueryParams).then((response) => {
        this.unitList = response.rows;
        this.loading = false;
      });
    },
    //翻译审批状态
    approveStatusFormat(row, column) {
      return this.getType(row, column);
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.queryParams.randomUnittypeId = this.form.randomUnittypeId;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.reset();
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.extractId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      Department().then((response) => {
        this.form.createBy = response.data.createBy;
        this.form.userId = response.data.userId;
      });
      this.reset();
      this.unitList = [];
      this.RandomList = [];
      this.open = true;
      this.title = "添加项目申请";
      this.uploadDisabled = false;
    },

    /** 新增项目施工按钮操作 */
    handleAdd2() {
      Department().then((response) => {
        this.form.createBy = response.data.createBy;
        this.form.userId = response.data.userId;
      });
      this.reset();
      this.unitList = [];
      this.RandomList = [];
      this.open = true;
      this.title = "新增施工项目";
      this.uploadDisabled = false;
      this.form.unitIdsTypeName = "施工企业库";
      this.form.unitIdsTypeId = 11;
      this.disabled = true;
    },

    /** 修改按钮操作 */
    handleUpdate(row) {
      if (row.extractApproveStatus == 1) {
        this.uploadDisabled = true;
      }
      if (
        row.randomUnittypeId == 1 ||
        row.randomUnittypeId == 3 ||
        row.randomUnittypeId == 4 ||
        row.randomUnittypeId == 9
      ) {
        this.showmake = false;
      } else {
        this.showmake = true;
      }
      const extractId = row.extractId || this.ids;
      //给抽取库判定字段传参
      this.unittype = row.randomUnittypeId;
      getExtract(extractId).then((response) => {
        this.form = response.data;
        if (response.data.extractSignUrl) {
          this.imgUrl = response.data.extractSignUrl.split(",");
        }
        this.open = true;
        this.title = "修改申请表";

        //回显-选择抽取库
        this.form.unitIdsTypeName = row.unitTypeName; //抽取单位类型名字
        this.form.unitIdsTypeId = row.randomUnittypeId; //抽取单位类型id
      });
      this.UnitqueryParams.unitType = row.randomUnittypeId;
      //用单位的备注，临时存储一下当前项目的id，传递到后台做查询参数
      this.UnitqueryParams.extractId = row.extractId;
      //根据抽取单位库的id进行判断，对表头进行替换
      if(this.UnitqueryParams.unitType!=15){
        randomlist(this.UnitqueryParams).then((response) => {
          this.unitList = response.rows;
          this.form.unitIds = response.rows.map((item) => item.unitId);
          this.form.isTick = response.rows.map(item => item.isTick);
          this.form.unitStatues = response.rows.map(item => item.unitStatues);
          //循环不显示项目进行中的单位
          //for(var i=0;i<this.unitList.length;i++){
          //if(this.unitList[i].unitStatues==3){
          //this.unitList.splice(i,i);
          //}
          //}
          this.loading = false;
        });
      }else{
        agentlist(this.UnitqueryParams).then((response) => {
          this.agentlist = response.rows;
          this.form.unitIds = response.rows.map((item) => item.agentid);
          this.form.isTick = response.rows.map(item => item.isTick);
          this.form.unitStatues = "0";
          //循环不显示项目进行中的单位
          //for(var i=0;i<this.unitList.length;i++){
          //if(this.unitList[i].unitStatues==3){
          //this.unitList.splice(i,i);
          //}
          //}
          this.loading = false;
        });
      }
      
      //清空排除单位记录数组
      this.RandomList = [];
    },
    // 打印按钮操作
    handleUpdatePrint(row) {
      const extractId = row.extractId || this.ids;
      this.RandomqueryParams.extractId = extractId;
      // listRandom(this.RandomqueryParams).then((response) => {
      //   console.log(response.rows);
      // });
      getExtract(extractId).then((response) => {
        this.form = response.data;
        this.form.unitTypeId = row.unitTypeId;
        this.openPrint = true;
        this.titlePrint = "";
      });
    },
    /** 单位详情 */
    unitShow(row) {
      const unitId = row.unitId || this.ids;
      getUnit(unitId).then((response) => {
        this.formUnit = response.data;
        this.unitopen = true;
        this.title = "单位详情";
      });
    },
    overcome(row) {
      this.unitId = row.unitId || this.ids;
      this.unittype = row.unitType || this.ids;
      this.unitName = row.unitName || this.ids;
      this.exclude = true;
      this.title = "排除单位";
    },
    // 保存排除理由
    excludeSave() {
      //创建一个排除实体类
      var RandomNew = {
        randomUnittypeId: null,
        randomBanRansom: null,
        randomUnitId: null,
        randomUnitName: null,
        extractId: null,
      };
      RandomNew.randomUnittypeId = this.unittype;
      RandomNew.randomUnitId = this.unitId;
      RandomNew.extractId = this.form.extractId;
      //表单区一样的名字
      RandomNew.randomBanRansom = this.form.randomBanRansom;
      RandomNew.randomUnitName = this.unitName;
      this.RandomList.push(RandomNew);
      this.exclude = false;

      //刷新单位库下的单位列表状态
      for (var i = 0; i < this.unitList.length; i++) {
        if (this.unitList[i].unitId == RandomNew.randomUnitId) {
          this.unitList[i].unitStatues = 1;
        }
      }
    },
    /** 提交项目申请按钮 */
    submitForm() {
      if (this.imgUrl.length > 0) {
        if (Array.isArray(this.form.extractSignUrl)) {
          this.form.extractSignUrl = this.form.extractSignUrl.join(",");
        }
        this.$refs["form"].validate((valid) => {
          if (valid) {
            this.form.RandomList = this.RandomList;
            this.form.extractApproveStatus = 1;
            const newForm = { ...this.form };
            newForm.listDto = [];
            const ids = newForm.unitIds;
            const ticks = newForm.isTick;
            const unitStatus = newForm.unitStatues;
            ids.forEach((item, index) =>
              newForm.listDto.push({
                unitId: item,
                isTick: ticks[index],
                unitStatus: unitStatus[index],
              })
            );
            delete newForm.unitIds;
            delete newForm.isTick;
            delete newForm.unitStatues;
            if (this.form.extractId != null) {
              updateExtract(newForm)
                .then((response) => {
                  if (this.RandomList.length != 0) {
                    for (var i = 0; i < this.RandomList.length; i++) {
                      addBanRandom(this.RandomList[i]).then((response) => {});
                    }
                  }
                  this.msgSuccess("修改成功");
                  this.open = false;
                  this.imgUrl = [];
                  this.getList();
                })
                .catch((err) => {
                  this.$message({ type: "error", message: "网络错误" });
                });
            } else {
              addExtract(newForm).then((response) => {
                this.msgSuccess("新增成功");
                // exId = response.data.extractId;
                // if (this.RandomList.length != 0) {
                // 	for(var i=0;i<this.RandomList.length;i++){
                // 	  this.RandomList[i].extractId = exId;
                // 	  addBanRandom(this.RandomList[i]).then(response => {
                // 	  })
                // 	}
                // };
                this.open = false;
                this.getList();
              });
            }
          }
        });
      } else {
        this.$message.error("请上传签字表后提交");
      }
    },
    /**还原按钮*/
    DeleteMappingBtn(row) {
      var _this = this;
      const unitId = row.unitId || this.ids;
      //获取项目id
      this.RandomqueryParamsList.extractId = this.form.extractId;
      //获取单位id
      this.RandomqueryParamsList.randomUnitId = unitId;
      //console.log(this.RandomqueryParams.randomUnitId);
      this.$confirm("是否需要复原?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        //判断当前是否有存储好的排除数据
        //刷新单位库下的单位列表状态
        for (var i = 0; i < _this.unitList.length; i++) {
          if (_this.unitList[i].unitId == row.unitId) {
            _this.unitList[i].unitStatues = 0;
          }
        }
        //清楚单位排除数组中本单位的信息（如果有）
        for (var k = 0; k < _this.RandomList.length; k++) {
          if (_this.RandomList[k].randomUnitId == row.unitId) {
            _this.RandomList.splice(k, 1);
          }
        }
        return DeleteMapping(_this.RandomqueryParamsList);
        //刷新表格
        this.UnitqueryParams.unitType = this.form.randomUnittypeId;
        this.UnitqueryParams.extractId = this.form.extractId;
        randomlist(this.UnitqueryParams).then((response) => {
          this.unitList = response.rows;
          this.loading = false;
        });
        this.msgSuccess("还原成功");
      }),
        () => {};
    },
    //单位详情提交按钮
    submitFormUnit() {
      this.unitopen = false;
      this.resetUnit();
    },
    /** 保存项目申请按钮 */
    saveForm() {
      if (Array.isArray(this.form.extractSignUrl)) {
        this.form.extractSignUrl = this.form.extractSignUrl.join(",");
      }
      this.$refs["form"].validate((valid) => {
          if (valid) {
            this.form.RandomList = this.RandomList;
            const newForm = { ...this.form };
            newForm.listDto = [];
            const ids = newForm.unitIds;
            const ticks = newForm.isTick;
            const unitStatus = newForm.unitStatues;
            ids.forEach((item, index) =>
              newForm.listDto.push({
                unitId: item,
                isTick: ticks[index],
                unitStatus: unitStatus[index],
              })
            );
            delete newForm.unitIds;
            delete newForm.isTick;
            delete newForm.unitStatues;
            if (this.form.extractId != null) {
              updateExtract(newForm)
                .then((response) => {
                  if (this.RandomList.length != 0) {
                    for (var i = 0; i < this.RandomList.length; i++) {
                      addBanRandom(this.RandomList[i]).then((response) => {});
                    }
                  }
                  this.msgSuccess("修改成功");
                  this.open = false;
                  this.imgUrl = [];
                  this.getList();
                })
                .catch((err) => {
                  this.$message({ type: "error", message: "网络错误" });
                });
            } else {
              addExtract(newForm).then((response) => {
                this.msgSuccess("新增成功");
                // exId = response.data.extractId;
                // if (this.RandomList.length != 0) {
                // 	for(var i=0;i<this.RandomList.length;i++){
                // 	  this.RandomList[i].extractId = exId;
                // 	  addBanRandom(this.RandomList[i]).then(response => {
                // 	  })
                // 	}
                // };
                this.open = false;
                this.getList();
              });
            }
            this.$refs.form.resetFields();
          }
        });
    },
    call() {
      this._data.exclude = false;
    },
    reason(row) {
      this.outframe = true;
      this.Random.randomUnitName = this.unitName;
      this.Random.randomUnittypeId = this.unittype;
      this.Random.randomUnitId = this.unitId;
    },
    determined() {
      this._data.outframe = false;
    },
    // confirm(){
    //   this.confirm=false
    // },
    /** 删除按钮操作 */
    handleDelete(row) {
      const extractIds = row.extractId || this.ids;
      this.$confirm(
        '是否确认删除项目申请编号为"' + extractIds + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          return delExtract(extractIds);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        });
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有项目申请数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return exportExtract(queryParams);
        })
        .then((response) => {
          this.download(response.msg);
        });
    },
    removeImg(index) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.imgUrl.splice(index, 1);
          this.extractSignUrl = this.imgUrl;
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    rowStyle({ row }) {
      let style = {};
      if (row.isTick == 0) style.backgroundColor = "#ffe4e1";
      return style;
    },
  },
  watch: {
    form: {
      deep: true,
      handler(newVal) {
        const priceStr = newVal.extractPrice?.split(".");
        const maxPrice = newVal.maxPrice?.split(".");
        if (priceStr && priceStr[1]?.length > 2) {
          const a = priceStr[1].split("");
          a.splice(2);
          priceStr[1] = a.join("");
          const newPrice = priceStr.join(".");
          newVal.extractPrice = newPrice;
        }
        if (maxPrice && maxPrice[1]?.length > 2) {
          const a = maxPrice[1].split("");
          a.splice(2);
          maxPrice[1] = a.join("");
          const newPrice = maxPrice.join(".");
          newVal.maxPrice = newPrice;
        }
      },
    },
  },
  filters: {
    dateTime(val) {
      if (val) {
        return val.substr(0, 10);
      }
    },
  },
};
</script>
<style lang="scss" scoped>
::v-deep .el-table .warning-row {
  background: oldlace;
}
::v-deep .el-table .denger-row {
  background: #ffe4e1;
}
::v-deep .el-table .cell {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
::v-deep .el-table .cell:hover {
  white-space: normal;
}
::v-deep .el-upload {
  text-align: left;
}
::v-deep .el-image {
  margin-right: 10px;
  margin-top: 10px;
}
::v-deep .el-upload-list {
  display: flex;
  flex-wrap: wrap;
}
::v-deep .el-upload-list__item {
  width: 50%;
}
.bigfont {
  font-size: 19px;
  font-weight: 100;
  text-align: center;
  font-family: FangSong;
}
.small {
  text-align: center;
  font-weight: 100;
  font-size: 16px;
}
.fontitem1 {
  vertical-align: top;
  font-size: 16px;
  font-weight: 100;
}
.fontitem12 {
  font-size: 16px;
}
.topfont {
  font-size: 16px;
  font-weight: 400;
}
.input {
  font-size: 18px;
  font-weight: 400;
}
.small1 {
  text-align: center;
  font-weight: 100;
  font-size: 20px;
}
.zhong {
  font-size: 16px;
  padding-left: 10px;
}
.title {
  margin-bottom: 30px;
  font-size: 24px;
  font-family: SimSun;
}
.project-name {
  font-family: FangSong;
}
.project-name-1 {
  font-family: FangSong;
}
.topfont-name {
  font-family: FangSong;
}
.font-family {
  font-family: FangSong;
}
.ceshi {
  width: 100%;
  height: 20px;
  text-align: left;
  line-height: 20px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding-left: 9px;
  color: #ff0000;
  font-size: 12px;
}
.printTable {
  border: unset;
}
.noBorder {
  border: unset;
}
.rightBorder {
  border-right: 1px solid #9a9a9a;
}
.bottomBorder {
  border-bottom: 1px solid #9a9a9a;
}
.image-wrap {
  display: flex;
  flex-wrap: wrap;
}
.uploadimg-wrap {
  position: relative;
  margin-right: 10px;
  .icon {
    cursor: pointer;
    position: absolute;
    top: -1px;
    right: 3px;
    font-size: 16px;
    color: red;
  }
}
.unitSort-box li {
  margin-top: 5px;
}
.form-img-out {
  width: 130px;
  height: 130px;
}
.form-img-line {
  width: 500px;
  height: 500px;
}
.form-dialog {
  text-align: center;
}

.reason-wrap {
  display: flex;
  .reason-title {
    width: 130px;
    text-align: right;
    font-weight: bold;
  }
  .reason {
    // border: 1px solid black;
    padding-left: 12px;
    width: 100%;
  }
  &:first-of-type {
    margin-bottom: 20px;
  }
}
</style>
